from Monitor.NetworkMonitor import NetworkDelayMonitor,NetworkMonitor,MonitorType,NetworkBandWidthMonitor
from containernet.node import DockerSta
from OSM_Mininet_wifi.node import OSMDockerStaion,OSMDockerCloud
from containernet.cli import CLI
from containernet.term import makeTerm
from mininet.log import info, setLogLevel,output
from mn_wifi.mobility import Mobility
from mininet.node import Controller
from OSM_Mininet_wifi.net import OSM_Mininet_wifi
from mn_wifi.net import OVSKernelAP

setLogLevel('info')
net = OSM_Mininet_wifi(controller=Controller,autoAssociation=False)


net.addStation(**{'type': 'mp', 'name': 'mp0', 'location': ['28.191202963839157,112.97478083409786', '28.1974083349244,112.98089627065184'], 'position': '-256,-529,0', 'ip': '10.0.0.1/8', 'ip6': '2001:0:0:0:0:0:0:1/64', 'mac': '00:00:00:00:00:01', 'range': 500, 'speed': 50, 'dimage': 'ubuntu:test2', 'sysctls': {'net.ipv6.conf.all.disable_ipv6': '0'}},cls=OSMDockerStaion)
net.OSM_Mobility_For_ConfigurationData(**{'NodeMobilityConfig': {'speed': 50, 'coord': ['-258,-516,0', '-245,-520,0', '-245,-512,0', '-246,-511,0', '-244,-501,0', '-239,-468,0', '-232,-415,0', '-179,-426,0', '-94,-454,0', '-75,-407,0', '-73,-392,0', '-68,-372,0', '-57,-311,0', '-54,-295,0', '-58,-276,0', '-56,-256,0', '-40,-181,0', '-37,-170,0', '-25,-158,0', '25,-32,0', '34,9,0', '47,67,0', '65,144,0', '69,264,0', '150,260,0', '159,256,0', '175,253,0', '178,259,0', '187,264,0', '198,259,0', '234,257,0', '254,251,0', '256,250,0', '264,244,0', '281,234,0', '296,224,0', '309,213,0', '317,200,0', '336,159,0'], 'distance': 1330.2200652328147}, 'node': 'mp0'})
net.addDocker(**{'type': 'ec', 'name': 'ec0', 'location': [28.194179552391397, 112.97352790832521], 'position': [-379, -198, 0], 'ip': '10.0.0.4/8', 'ip6': '2001:0:0:0:0:0:0:4/64', 'mac': '00:00:00:00:00:04', 'range': 500, 'dimage': 'ubuntu:test2', 'sysctls': {'net.ipv6.conf.all.disable_ipv6': '0'}},cls=OSMDockerCloud)
net.addAccessPoint(**{'type': 'bs', 'name': 'bs2', 'location': [28.193839282063895, 112.97494411468507], 'position': [-240, -236, 0], 'ssid': 'ssid-bs2', 'ip': '10.0.0.5/8', 'ip6': '2001:0:0:0:0:0:0:5/64', 'mac': '00:00:00:00:00:05', 'range': 500, 'failMode': 'standalone'})
net.addAccessPoint(**{'type': 'bs', 'name': 'bs3', 'location': [28.19576243318881, 112.98250559606075], 'position': [501, -22, 0], 'ssid': 'ssid-bs3', 'ip': '10.0.0.6/8', 'ip6': '2001:0:0:0:0:0:0:6/64', 'mac': '00:00:00:00:00:06', 'range': 500, 'failMode': 'standalone'})
net.addDocker(**{'type': 'ec', 'name': 'ec1', 'location': [28.196651601642262, 112.98387888707637], 'position': [636, 77, 0], 'ip': '10.0.0.7/8', 'ip6': '2001:0:0:0:0:0:0:7/64', 'mac': '00:00:00:00:00:07', 'range': 500, 'dimage': 'ubuntu:test2', 'sysctls': {'net.ipv6.conf.all.disable_ipv6': '0'}},cls=OSMDockerCloud)
net.addDocker(**{'type': 'ec', 'name': 'ec2', 'location': [28.203751084273858, 112.97786235809328], 'position': [46, 866, 0], 'ip': '10.0.0.8/8', 'ip6': '2001:0:0:0:0:0:0:8/64', 'mac': '00:00:00:00:00:08', 'range': 500, 'dimage': 'ubuntu:test2', 'sysctls': {'net.ipv6.conf.all.disable_ipv6': '0'}},cls=OSMDockerCloud)
net.addAccessPoint(**{'type': 'ap', 'name': 'ap4', 'location': [28.202932325545056, 112.97883633412837], 'position': [142, 775, 0], 'ssid': 'ssid-ap4', 'ip': '10.0.0.9/8', 'ip6': '2001:0:0:0:0:0:0:9/64', 'mac': '00:00:00:00:00:09', 'range': 50, 'failMode': 'standalone'})
net.startController(**{'controller': 'None', 'name': 'c', 'number': 1, 'ip': '127.0.0.1', 'port': 6653, 'protocol': 'tcp', 'app': 'simple_switch'})
net.configureWifiNodes()
net.addLink(**{'type': 'nl', 'node1': 'ec0', 'node2': 'bs2', 'delay': '0ms', 'bw': 10, 'jitter': '0ms', 'loss': 0})
net.addLink(**{'type': 'nl', 'node1': 'bs3', 'node2': 'ec1', 'delay': '0ms', 'bw': 10, 'jitter': '0ms', 'loss': 0})
net.addLink(**{'type': 'nl', 'node1': 'bs2', 'node2': 'ap4', 'delay': '0ms', 'bw': 10, 'jitter': '0ms', 'loss': 0})
net.addLink(**{'type': 'nl', 'node1': 'bs3', 'node2': 'ap4', 'delay': '0ms', 'bw': 10, 'jitter': '0ms', 'loss': 0})
net.addLink(**{'type': 'nl', 'node1': 'ap4', 'node2': 'ec2', 'delay': '0ms', 'bw': 10, 'jitter': '0ms', 'loss': 0})
net.OSM_Mobility_Setting(**{'mobility_start_time': 1, 'reverse': 0, 'ac_method': 'ssf', 'mob_rep': 1, 'mobility_mode': 'quickly'})
net.start()
thread_list = []
t=NetworkDelayMonitor('mp0', 'ec0', net, monitor_type= {'delay'}).start(data_storage_Directory='/home/kylin/Desktop/PythonProject/OSM_Mininet_WIFI/Mininet_WIFI/Network_Topology/Network_Topology_20240327154039043557.json',**{'period': 10}).thread_
thread_list.append(t)
for td in thread_list: td.join()
net.OSM_Experiment_Ended(data_storage_Directory='/home/kylin/Desktop/PythonProject/OSM_Mininet_WIFI/Mininet_WIFI/Network_Topology/Network_Topology_20240327154039043557.json')
net.stop()
